function goodMood(msg){
    layer.alert(msg, {icon: 6,time:3000});
}

function badMood(msg){
    layer.alert(msg, {icon: 5,time:3000});
}
function fillData(which,id,dataStat){
    $.ajax({
        type: "post",
        url: ctx+"/data",
        data: {id:id},
        dataType: "text",
        async : false, //同步请求
        success: function(data){
            var html = "<dd><ul>";
            var list = $.parseJSON(data);
            var len = list.length;
            for (var i=0;i<len;i++){
                var temp = list[i];
                var id = "'";
                id += temp.id;
                id += "'";
                html += '<li onclick="contentData('+id+',this);">';
                    html += "<a href='javascript:void(0);' title='"+temp.name+"'>";
                        html += dataStat+".";
                        html += (i+1);
                        html += " ";
                        html += temp.name;
                    html += "</a>";
                html += "</li>";
            }
            html += "</ul></dd>";
            $(which).after(html);
        },
        error:function(err){
            badMood("服务器异常，请稍后重试！");
        }
    });
}


function contentData(id,which) {
    $(which).css("background-color","#777777").siblings().css("background-color","#333333");
    $.ajax({
        type: "get",
        url: ctx + "/getOne",
        data: {id: id},
        dataType: "text",
        async: false, //同步请求
        success: function (data) {
            var one = $.parseJSON(data);

            var html = '<div class="panel panel-default" style="font-size: 20px;"> ';
            html += '<div class="panel-header">' + one.name + '接口基本信息</div>           ';
            html += '<div class="panel-body">          ';
            html += '<div>    ';
            html += '<label>请求方式：</label><span>' + one.requestType + '</span>       ';
            html += '</div>           ';
            html += '<div>   ';
            html += '<label>请求地址：</label><span>http://{ip}:{port}/{projectName}&nbsp;&nbsp;&nbsp;&nbsp;' + one.requestUrl + '</span>    ';
            html += '</div>         ';
            html += '</div>  ';
            html += '</div> ';

            html += '<h3>Request</h3>';
            html += '<pre class="prettyprint" style="font-size: 20px;">';
            html += one.request;
            html += '</pre>';

            html += '<h3>Response</h3>';
            html += '<pre class="prettyprint" style="background-color: #ebebe4;font-size: 20px;">';
            html += one.response;
            html += '</pre>';

            html += '<h3>接口其它说明</h3>';
            html += '<pre class="prettyprint" style="font-size: 20px;">';
            if (one.descr) {
                html += one.descr;
            } else {
                html += "暂无……";
            }
            html += '</pre>';
            $("#content").html("");
            $("#content").append(html);
        },
        error: function (err) {
            badMood("服务器异常，请稍后重试！");
        }
    });

}



function switchModel(flag){
    if (flag==1){
        $("#one").css("display","");
        $("#two").css("display","none");
    }else if(flag==2){
        $("#two").css("display","");
        $("#one").css("display","none");
    }
}


function modelData(flag,parentId){
    if (parentId){
        window.location = ctx +"/back/?switchModel="+flag+"&parentId="+parentId;
    }else{
        window.location = ctx +"/back/?switchModel="+flag;
    }

}


















